home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / Apache / include / apache / http_protocol.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-06  |  9.0 KB  |  225 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * Portions of this software are based upon public domain software
  55.  * originally written at the National Center for Supercomputing Applications,
  56.  * University of Illinois, Urbana-Champaign.
  57.  */
  58.  
  59. #ifndef APACHE_HTTP_PROTOCOL_H
  60. #define APACHE_HTTP_PROTOCOL_H
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. /*
  67.  * Prototypes for routines which either talk directly back to the user,
  68.  * or control the ones that eventually do.
  69.  */
  70.  
  71. /* Read a request and fill in the fields. */
  72.  
  73. request_rec *ap_read_request(conn_rec *c);
  74.  
  75. /* Send a single HTTP header field */
  76.  
  77. API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r, const char *fieldname,
  78.                       const char *fieldval);
  79.  
  80. /* Send the minimal part of an HTTP response header... but modules should be
  81.  * very careful about using this, and should prefer ap_send_http_header().
  82.  * Much of the HTTP/1.1 implementation correctness depends on code in
  83.  * ap_send_http_header().
  84.  */
  85. API_EXPORT(void) ap_basic_http_header(request_rec *r);
  86.  
  87. /* Send the Status-Line and header fields for HTTP response */
  88.  
  89. API_EXPORT(void) ap_send_http_header(request_rec *l);
  90.  
  91. /* Send the response to special method requests */
  92.  
  93. API_EXPORT(int) ap_send_http_trace(request_rec *r);
  94. int ap_send_http_options(request_rec *r);
  95.  
  96. /* Finish up stuff after a request */
  97.  
  98. API_EXPORT(void) ap_finalize_request_protocol(request_rec *r);
  99.  
  100. /* Send error back to client... last arg indicates error status in case
  101.  * we get an error in the process of trying to deal with an ErrorDocument
  102.  * to handle some other error.  In that case, we print the default report
  103.  * for the first thing that went wrong, and more briefly report on the
  104.  * problem with the ErrorDocument.
  105.  */
  106.  
  107. API_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error);
  108.  
  109. /* Set last modified header line from the lastmod date of the associated file.
  110.  * Also, set content length.
  111.  *
  112.  * May return an error status, typically USE_LOCAL_COPY (that when the
  113.  * permit_cache argument is set to one).
  114.  */
  115.  
  116. API_EXPORT(int) ap_set_content_length(request_rec *r, long length);
  117. API_EXPORT(int) ap_set_keepalive(request_rec *r);
  118. API_EXPORT(time_t) ap_rationalize_mtime(request_rec *r, time_t mtime);
  119. API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak);
  120. API_EXPORT(void) ap_set_etag(request_rec *r);
  121. API_EXPORT(void) ap_set_last_modified(request_rec *r);
  122. API_EXPORT(int) ap_meets_conditions(request_rec *r);
  123.  
  124. /* Other ways to send stuff at the client.  All of these keep track
  125.  * of bytes_sent automatically.  This indirection is intended to make
  126.  * it a little more painless to slide things like HTTP-NG packetization
  127.  * underneath the main body of the code later.  In the meantime, it lets
  128.  * us centralize a bit of accounting (bytes_sent).
  129.  *
  130.  * These also return the number of bytes written by the call.
  131.  * They should only be called with a timeout registered, for obvious reaasons.
  132.  * (Ditto the send_header stuff).
  133.  */
  134.  
  135. API_EXPORT(long) ap_send_fd(FILE *f, request_rec *r);
  136. API_EXPORT(long) ap_send_fd_length(FILE *f, request_rec *r, long length);
  137.  
  138. API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r);
  139. API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length);
  140.  
  141. API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset,
  142.                              size_t length);
  143.  
  144. /* Hmmm... could macrofy these for now, and maybe forever, though the
  145.  * definitions of the macros would get a whole lot hairier.
  146.  */
  147.  
  148. API_EXPORT(int) ap_rputc(int c, request_rec *r);
  149. API_EXPORT(int) ap_rputs(const char *str, request_rec *r);
  150. API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
  151. API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...);
  152. API_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
  153. API_EXPORT_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
  154.                 __attribute__((format(printf,2,3)));
  155. API_EXPORT(int) ap_rflush(request_rec *r);
  156.  
  157. /*
  158.  * Index used in custom_responses array for a specific error code
  159.  * (only use outside protocol.c is in getting them configured).
  160.  */
  161.  
  162. API_EXPORT(int) ap_index_of_response(int status);
  163.  
  164. /* Reading a block of data from the client connection (e.g., POST arg) */
  165.  
  166. API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy);
  167. API_EXPORT(int) ap_should_client_block(request_rec *r);
  168. API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz);
  169. API_EXPORT(int) ap_discard_request_body(request_rec *r);
  170.  
  171. /* Sending a byterange */
  172.  
  173. API_EXPORT(int) ap_set_byterange(request_rec *r);
  174. API_EXPORT(int) ap_each_byterange(request_rec *r, long *offset, long *length);
  175.  
  176. /* Support for the Basic authentication protocol.  Note that there's
  177.  * nothing that prevents these from being in mod_auth.c, except that other
  178.  * modules which wanted to provide their own variants on finding users and
  179.  * passwords for Basic auth (a fairly common request) would then require
  180.  * mod_auth to be loaded or they wouldn't work.
  181.  *
  182.  * get_basic_auth_pw returns 0 (OK) if it set the 'pw' argument (and assured
  183.  * a correct value in r->connection->user); otherwise it returns an error
  184.  * code, either SERVER_ERROR if things are really confused, AUTH_REQUIRED
  185.  * if no authentication at all seemed to be in use, or DECLINED if there
  186.  * was authentication but it wasn't Basic (in which case, the caller should
  187.  * presumably decline as well).
  188.  *
  189.  * note_basic_auth_failure arranges for the right stuff to be scribbled on
  190.  * the HTTP return so that the client knows how to authenticate itself the
  191.  * next time. As does note_digest_auth_failure for Digest auth.
  192.  *
  193.  * note_auth_failure does the same thing, but will call the correct one
  194.  * based on the authentication type in use.
  195.  *
  196.  */
  197.  
  198. API_EXPORT(void) ap_note_auth_failure(request_rec *r);
  199. API_EXPORT(void) ap_note_basic_auth_failure(request_rec *r);
  200. API_EXPORT(void) ap_note_digest_auth_failure(request_rec *r);
  201. API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
  202.  
  203. /*
  204.  * Setting up the protocol fields for subsidiary requests...
  205.  * Also, a wrapup function to keep the internal accounting straight.
  206.  */
  207.  
  208. void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
  209. void ap_finalize_sub_req_protocol(request_rec *sub_r);
  210.  
  211. /* This is also useful for putting sub_reqs and internal_redirects together */
  212.  
  213. CORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri);
  214.  
  215. /* Get the method number associated with the given string, assumed to
  216.  * contain an HTTP method.  Returns M_INVALID if not recognized.
  217.  */
  218. API_EXPORT(int) ap_method_number_of(const char *method);
  219.  
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223.  
  224. #endif    /* !APACHE_HTTP_PROTOCOL_H */
  225.